package com.jlcindia.hibernate;

import org.hibernate.*;
public class Lab37 
{
	public static void main(String args[])
	{
		Transaction tx=null;
		try
		{
			SessionFactory sf=HibernateUtil.getSessionFactory();
			Session session=sf.openSession();
			tx=session.beginTransaction();
			SID id = SIDGenerator.getNexSid("30");
			Student student = new Student(id, "vas", "vas@jlc", "9999");
			session.save(student);
			Student student2 = (Student)session.load(Student.class, new SID("31", "102"));
			System.out.println(student2.getStudentId().getBid());
			System.out.println(student2.getStudentId().getSid());
			//System.out.println(student2.getSname());
			//System.out.println(student2.getEmail());
			//System.out.println(student2.getPhone());
			tx.commit();
			session.close();
		}
		catch (Exception e) 
		{
			e.printStackTrace();
			if(tx!=null)
				tx.rollback();
		}
	}
}
